package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.pojo.DtsAddress;
import com.qf.service.DtsAdminAddressService;
import com.qf.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/admin/address")
public class DtsAdminAddressController {

    @Autowired
    DtsAdminAddressService adminAddressService;

    @RequestMapping("/list")
    public Object list( @RequestParam(value = "page",required = false,defaultValue = "1") Integer page,
                        @RequestParam(value = "limit",required = false,defaultValue = "10") Integer limit,
                        String sort, String order,String name,Integer userId){

        IPage<DtsAddress> iPage = adminAddressService.queryPage(page,limit,sort,order,name,userId);
        Map<String,Object> data = new HashMap<>();
        data.put("total",iPage.getTotal());
        data.put("items",iPage.getRecords());
        return ResponseUtil.ok(data);
    }
}
